<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
    <title><!--候补排序列表--></title>
    <meta charset="utf-8">
    <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
	<link rel="stylesheet" href="css/project/ui-input-v3.css">
	<link rel="stylesheet" href="css/ui-base.css">
	<link rel="stylesheet" href="css/ui-box.css">
	<link rel="stylesheet" href="css/project/style.css">
	<link rel="stylesheet" href="css/zv_common.css"> 
	<link rel="stylesheet" href="css/project/ui-color-v3.css">
	<link rel="stylesheet" href="css/project/ui-res-v3.css">
	<link rel="stylesheet" href="css/iBox.css?v=202022">
	<script src="js/zy_control.js"></script>
	<script src="js/zy_click.js"></script>
	<script src="js/jquery-3.1.1.min.js?v=202021"></script>
	<script src="js/main.js"></script>
	<script src="js/init.js"></script>
	<script src="js/iBox.js?v=202022"></script>
	<script src="js/appcan.min.js"></script>
	<script src="js/candidate.js"></script>
	<script src="js/talkingdata.js"></script>
	<style type="text/css" media="screen">
		  #candidates{
            overflow-y:scroll;
            -webkit-overflow-scrolling:touch; 
            }
	</style>
</head>
<body class="um-vp" ontouchstart>
<div id="page_1" class="ub ub-ver um-vp">
<form action="javascript:;" method="get" id="search_form" name="search_form">	
<div class="ub ub-ver" style="clear:both;">
</div>
</form>
<!---查询列表显示-->
<div id="candidates">
</div>
</div>
<script>
zy_init();
var path = "http://jx.selfservice.ceair.com:6080/mckiserver/service/v1/sample";
//var path = "http://172.31.68.222:7080/mckiserver/service/v1/sample"; //测试地址
var candidateList='';
window.uexOnload=function(type)
{
	if(!type){

		IC.talkingDataCount("旅客候补","0001");
	}
}
/**
 * 获取候补列表
 */
function CandidateSort()
{
	IC.talkingDataCount("旅客候补","0001");
	candidateList='';
	$("#candidates").empty();   
	var url = path+"/CandidateSort";
	var CarrierD = getStorage("candidateList_Carrier"); /*承运人*/
	var flightNoD = getStorage("candidateList_flightNo"); /*航班号*/
	var flightDateD=getStorage("candidateList_flightDate");/*航班日期*/
	var oriEngD1 = getStorage("candidateList_oriEng"); /*出发机场3字码*/
	var oriEngD=oriEngD1.toUpperCase();
	var desEng1 = getStorage("candidateList_desEng"); /*到达机场3字码*/
	var desEng=desEng1.toUpperCase();
	var imei=getDevice()==""?"340403199003170612":getDevice();
	SubClasslv=getStorage("candidateList_SubClasslv");
	if(SubClasslv=='')
	{
		$alert("请选择舱位！");
		return;
	}
	if(flightNoD=='')
	{
		$alert("请输入航班号！");
		return;
	}
//	flightNoD='5107';  //test;
	var paramList="<?xml version=\"1.0\" encoding=\"utf-8\" ?><candidateSortBean><carrier><![CDATA["+CarrierD+"]]></carrier><flightNo><![CDATA["+flightNoD+"]]></flightNo><depDt><![CDATA["+flightDateD+"]]></depDt><oriEng><![CDATA["+oriEngD+"]]></oriEng><desEng><![CDATA["+desEng+"]]></desEng><subclassLv><![CDATA["+SubClasslv+"]]></subclassLv><calluser><![CDATA["+calluser+"]]></calluser><username><![CDATA["+username+"]]></username><password><![CDATA["+password+"]]></password><imei><![CDATA["+imei+"]]></imei></candidateSortBean>";
		
		$.iBoxWait();
			$.ajax({
				type: "POST",
				contentType: "text/xml; charset=utf-8",
				url: url,
				data: paramList,
				dataType: "text",//"xml", "html", "script", "json", "jsonp", "text".
				success: function(data){ 
				  //后台数据返回格式有不同！！！(单个返回是json对象，多个返回是jsonArray对象)
				  //alert(paramList);
					$.iBoxHide();
					 json=JSON.parse(data);
//					candidateJson=JSON.stringify(json);
					console.log("data: "+data);
					//alert(paramList);
					if(json.candidateOutputBean.errorCodeM==0)
					{
						if(data.indexOf("mckiList")>-1)
						{
							var mckiList=data.substring(data.indexOf("mckiList")+10);
							LayOutList(mckiList,json.candidateOutputBean.mckiList);
						}
						else{
							$alert("暂无数据！");   //暂无数据
						}
						
					}else
					{
						$alert(json.candidateOutputBean.errorMsgM);
					}
				},
				//调用出错执行的函数
				error: function(err){
					$.iBoxHide();
					$alert("暂无相关信息！");
				}
			});
}

function LayOutList(data,mckiListJson)
{
//	console.log("mckiListJson: "+JSON.stringify(mckiListJson));
	var arrlist=data.split("},{");
	var len=arrlist.length;
	for (var i = 0; i < len; i++) {
		var carrier='';       //承运商
		var flightNo='';             //航班号
		var oriEng='';                //始发站
		var desEng= '';                 //到达站
		var paxname= '';              //旅客姓名
		var subclassLv= '';              //舱位
		var waitTime='';               //候补时间
		var idNum= '';                //证件号码
		var rankVal= '';           //级别 
		var seqIndex='';   //旅客排序
		var mcv= '';                //MCV
		var sri= '';                //SRI
		var ffpLevel='';     //金卡银卡
		var orderGrade='';  //旅客排序
		
		var subArr=arrlist[i].split(",");
		for(var j=0;j<subArr.length;j++)
		{
			if(subArr[j].indexOf("carrier")>-1)
			{
				var arrCarrier=subArr[j].split(":");
				carrier=arrCarrier[1].substring(arrCarrier[1].indexOf('"')+1);
				carrier=carrier.replace('"','');
			}
			else if(subArr[j].indexOf("flightNo")>-1)
			{
				var arrFlightNo=subArr[j].split(":");
				flightNo=arrFlightNo[1].substring(arrFlightNo[1].indexOf('"')+1);
				flightNo=flightNo.replace('"','');
				flightNo=flightNo.length<4?flightNo+'&nbsp ':flightNo;
			}
			else if(subArr[j].indexOf("oriEng")>-1)
			{
				var arrOriEng=subArr[j].split(":");
				oriEng=arrOriEng[1].substring(arrOriEng[1].indexOf('"')+1);
				oriEng=oriEng.replace('"','');
			}
			else if(subArr[j].indexOf("desEng")>-1)
			{
				var arrDesEng=subArr[j].split(":");
				desEng=arrDesEng[1].substring(arrDesEng[1].indexOf('"')+1);
				desEng=desEng.replace('"','');
			}
			else if(subArr[j].indexOf("paxname")>-1)
			{
				var arrPaxname=subArr[j].split(":");
				paxname=arrPaxname[1].substring(arrPaxname[1].indexOf('"')+1);
				paxname=paxname.replace('"','');
				paxname=paxname.replace(/[\\]/g,'');   //过滤掉/ \字符
			}
			else if(subArr[j].indexOf("waitTime")>-1)
			{
				var t1=subArr[j].substring(subArr[j].indexOf('":"')+1)
				waitTime=t1.replace(/"/g,'');
				waitTime=waitTime.split(":")[1];
		 		// /waitTime=waitTime.replace('T',' '); 
			}
			else if(subArr[j].indexOf("idNum")>-1)
			{
				var arrIdNum=subArr[j].split(":");
				idNum=arrIdNum[1].substring(arrIdNum[1].indexOf('"')+1);
				idNum=idNum.replace('"','');
				idNum=IdShowHandler(idNum);
			}
			else if(subArr[j].indexOf("rankVal")>-1)
			{
				var arrRankVal=subArr[j].split(":");
				rankVal=arrRankVal[1].substring(arrRankVal[1].indexOf('"')+1);
				rankVal=rankVal.replace('"','');
			}
			else if(subArr[j].indexOf("seqIndex")>-1)
			{
				var arrSeqIndex=subArr[j].split(":");
				seqIndex=arrSeqIndex[1].substring(arrSeqIndex[1].indexOf('"')+1);
				seqIndex=seqIndex.replace('"','');
			}else if(subArr[j].indexOf("mcv")>-1)
			{
				var arrMcv=subArr[j].split(":");
				mcv=arrMcv[1].substring(arrMcv[1].indexOf('"')+1);
				mcv=mcv.replace('"','');

			}
			else if(subArr[j].indexOf("sri")>-1)
			{
				var arrSri=subArr[j].split(":");
				
				sri=arrSri[1].substring(arrSri[1].indexOf('"')+1);
				sri=sri.replace('"','').split("}")[0];
			}else if(subArr[j].indexOf("ffpLevel")>-1)
			{
				var arrFfpLevel=subArr[j].split(":");
				ffpLevel=arrFfpLevel[1].substring(arrFfpLevel[1].indexOf('"')+1);
				ffpLevel=ffpLevel.replace('"','');
			}else if(subArr[j].indexOf("orderGrade")>-1)
			{
				var arrOrderGrade=subArr[j].split(":");
				orderGrade=arrOrderGrade[1].substring(arrOrderGrade[1].indexOf('"')+1);
				orderGrade=orderGrade.replace('"','');
			}
		}
		
		if(len==1)
		{
				if(mckiListJson.subclassLv!=undefined)
				{
					subclassLv=mckiListJson.subclassLv;
				}
				else{
				     subclassLv='';
				}
		}else{
				if(mckiListJson[i].subclassLv!=undefined)
				{
					subclassLv=mckiListJson[i].subclassLv;
				}
				else{
					subclassLv='';
				}
		}

		if(ffpLevel=='普通卡'){
			ffpLevel='普卡';
		}
		
		var logoStr='';
		if(flightNo!='')
		{
			logoStr='<div class="ub ub-ac clogo">\
										<div class="ub ub-ac"><img src="images/logo5.png"  style="width:1em"></div>\
										<div class="ub ub-ac">'+carrier+flightNo+'</div>\
									</div>';
		}
		//常客登机未空是不显示
	    if (ffpLevel == ''){
			var candidateSubList='<div class="uba umar-a cbg boxf ub ub-ac" onclick="DetailPage(\''+paxname+'\',\''+idNum+'\',\''+oriEng+'\',\''+desEng+'\',\''+waitTime+'\',\''+mcv+'\',\''+sri+'\')">\
									<div class="ub " style="width:23%;">\
									'+logoStr+'\
							</div>\
							<div class="ub ub-ver ctxt1" >\
							<div class="ub ub-ac wtop "><div class="ub ub-ac wb"><span class="ctxtsp">旅客姓名：</span>'+paxname+'</div><div class="ub ub-ac wb"><span class="ctxtsp">候补舱位：</span>'+subclassLv+'</div></div>\
							<div class="ub ub-ac"><div class="ub ub-ac wb"><span class="ctxtsp">旅客排序：</span>'+orderGrade+'</div></div>\
							</div>\
					   </div>';
		}
		else{
			if(ffpLevel=="null"||ffpLevel==null){
				ffpLevel="";
			}
			// alert(paxname);
			// alert(idNum);
			// alert(oriEng);
			// alert(desEng);
			// alert(waitTime);
			// alert(mcv);
			// alert(sri);
			var candidateSubList='<div class="uba umar-a cbg boxf" onclick="DetailPage(\''+paxname+'\',\''+idNum+'\',\''+oriEng+'\',\''+desEng+'\',\''+waitTime+'\',\''+mcv+'\',\''+sri+'\')">\
									<div class="ub " style="width:23%;">\
									'+logoStr+'\
							</div>\
							<div class="ub ub-ver ctxt1" >\
							<div class="ub ub-ac wtop "><div class="ub ub-ac wb"><span class="ctxtsp">旅客姓名：</span>'+paxname+'</div><div class="ub ub-ac wb"><span class="ctxtsp">候补舱位：</span>'+subclassLv+'</div></div>\
							<div class="ub ub-ac"><div class="ub ub-ac wb"><span class="ctxtsp">旅客排序：</span>'+orderGrade+'</div><div class="ub ub-ac"><span class="ctxtsp">常客等级：</span>'+ffpLevel+'</div></div>\
							</div>\
					   </div>';
		}
		
					   
		candidateList+=candidateSubList;
	}
	var search_form=$$("search_form").offsetHeight;
	var bodyH = document.body.clientHeight;
	$$("candidates").style.height=(bodyH-search_form)+"px";
	$$("candidates").innerHTML = candidateList;
}

function DetailPage(paxname,idNum,oriEng,desEng,waitTime,mcv,sri)
{
	setStorage("candidateList_paxname",paxname);
	setStorage("candidateList_idNum",idNum);
	setStorage("candidateList_oriEng",oriEng);
	setStorage("candidateList_desEng",desEng);
	setStorage("candidateList_waitTime",waitTime);
	setStorage("candidateList_mcv",mcv);
	setStorage("candidateList_sri",sri);
	openNewWin('candidateListDetail','candidateListDetail.html');
	//IC.talkingDataCount("旅客候补","0001");
}
</script>
</body>
</html>
